<template>
  <a-tree-select
    :treeData="data"
    :dropdownStyle="{ maxHeight: '400px', overflow: 'auto' }"
    :placeholder="$t('m.bpm.other.qing-xuan-ze-mo-ban-fen-lei')"
    allowClear
    treeDefaultExpandAll
    @change="handleChange"
  >
  </a-tree-select>
</template>

<script>

  import {getAction} from '@/api/manage';
  import YchConstant from "@/api/YchConstant";

  export default {
    name: "BpmCatalogSelect",
    components: {},
    data() {
      return {
        data: [],
        url: {
          getCatalogTree: YchConstant.PREFIX_BPM + "/bpm-back/processDefRest/getCatalogTree/v1"
        }
      }
    },
    methods: {
      init() {
        const that = this;
        getAction(this.url.getCatalogTree, {}).then((res) => {
          if (res.success) {
            that.data = res.result;
          } else {
            that.messageUtil.warning(res.message)
          }
        });
      },
      handleChange(value, label) {
        this.$emit('selectFinished', value, label);
      }
    },
    mounted() {
      this.init();
    }
  }
</script>
